package com.ruoyi.web.controller.pollutant;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pollutant.domain.OutletSolid;
import com.ruoyi.pollutant.service.IOutletSolidService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 固体废物排放Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/pollutant/solid")
public class OutletSolidController extends BaseController
{
    @Autowired
    private IOutletSolidService outletSolidService;

    /**
     * 查询固体废物排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutletSolid outletSolid)
    {
        startPage();
        List<OutletSolid> list = outletSolidService.selectOutletSolidList(outletSolid);
        return getDataTable(list);
    }

    /**
     * 导出固体废物排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:export')")
    @Log(title = "固体废物排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OutletSolid outletSolid)
    {
        List<OutletSolid> list = outletSolidService.selectOutletSolidList(outletSolid);
        ExcelUtil<OutletSolid> util = new ExcelUtil<OutletSolid>(OutletSolid.class);
        return util.exportExcel(list, "固体废物排放数据");
    }

    /**
     * 获取固体废物排放详细信息
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:query')")
    @GetMapping(value = "/{soId}")
    public AjaxResult getInfo(@PathVariable("soId") Long soId)
    {
        return AjaxResult.success(outletSolidService.selectOutletSolidById(soId));
    }

    /**
     * 新增固体废物排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:add')")
    @Log(title = "固体废物排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutletSolid outletSolid)
    {
        return toAjax(outletSolidService.insertOutletSolid(outletSolid));
    }

    /**
     * 修改固体废物排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:edit')")
    @Log(title = "固体废物排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutletSolid outletSolid)
    {
        return toAjax(outletSolidService.updateOutletSolid(outletSolid));
    }

    /**
     * 删除固体废物排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:solid:remove')")
    @Log(title = "固体废物排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{soIds}")
    public AjaxResult remove(@PathVariable Long[] soIds)
    {
        return toAjax(outletSolidService.deleteOutletSolidByIds(soIds));
    }
}
